package org.mashart.pink.m.gui;

import java.io.IOException;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * Splash screen that's shown initialy during the app initialization
 */
public class SplashScreen extends Canvas {

    /**
     * all it does is paints our logo on the canvas
     */
	protected void paint(Graphics g) {
		// get the dimensions of the screen:
		int width = getWidth ();
		int height = getHeight();
		
		// clear the screen (paint it white):
		g.setColor(0xffffff);
		
		// The first two args give the coordinates of the top
		// left corner of the rectangle. (0,0) corresponds
		// to the top-left corner of the screen.
		g.fillRect(0, 0, width, height);

        /* TODO move the following part into a constructor or
         *      whatever init code so we don't have to re-create
         *      the image every time. */
		try {
			Image img = Image.createImage("/splash.jpg");
			g.drawImage(img, width / 2, height / 2, Graphics.HCENTER | Graphics.VCENTER);
		} catch (IOException e) {
			// couldn't get the image
            /* TODO draw some text instead of the logo, maybe? */
		}
	}

}
